/*
 * PanelLicencia.java
 *
 * Created on 31 de diciembre de 2007, 18:09
 */

package com.codeko.apps.campanilla.ignotus;

import java.awt.Desktop;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author  campanilla
 */
public class PanelLicencia extends javax.swing.JPanel {
    
    /** Creates new form PanelLicencia */
    public PanelLicencia() {
        String inputLine;
        String inputText = "";
        
            initComponents();
            URL lic = PanelLicencia.class.getResource("Licencia.html");
            try {
                // Volcamos lo recibido al buffer
                BufferedReader in = new BufferedReader(new InputStreamReader(lic.openStream()));
                while ((inputLine = in.readLine()) != null) {
                    inputText = inputText + inputLine;
                }
            } catch (Throwable t) {
            }
            taLicencia.setText(inputText);
       
        
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        scrollLicencia = new javax.swing.JScrollPane();
        taLicencia = new javax.swing.JTextPane();
        bIrAGNU = new javax.swing.JButton();
        bVerLicencia = new javax.swing.JButton();

        setName("Form"); // NOI18N

        scrollLicencia.setName("scrollLicencia"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(com.codeko.apps.campanilla.ignotus.IgnotusApp.class).getContext().getResourceMap(PanelLicencia.class);
        taLicencia.setContentType(resourceMap.getString("taLicencia.contentType")); // NOI18N
        taLicencia.setName("taLicencia"); // NOI18N
        scrollLicencia.setViewportView(taLicencia);

        bIrAGNU.setText(resourceMap.getString("bIrAGNU.text")); // NOI18N
        bIrAGNU.setName("bIrAGNU"); // NOI18N
        bIrAGNU.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bIrAGNUActionPerformed(evt);
            }
        });

        bVerLicencia.setText(resourceMap.getString("bVerLicencia.text")); // NOI18N
        bVerLicencia.setName("bVerLicencia"); // NOI18N
        bVerLicencia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bVerLicenciaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(scrollLicencia, javax.swing.GroupLayout.DEFAULT_SIZE, 656, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(bIrAGNU, javax.swing.GroupLayout.PREFERRED_SIZE, 316, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(bVerLicencia, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bIrAGNU)
                    .addComponent(bVerLicencia))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE)
                .addComponent(scrollLicencia, javax.swing.GroupLayout.PREFERRED_SIZE, 389, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void bIrAGNUActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bIrAGNUActionPerformed
        try {
            Desktop.getDesktop().browse(new URI("http://www.fsf.org/"));
        } catch (Exception ex) {
            //TODO Implementar eeerrorr  I18N
            Logger.getLogger(PanelLicencia.class.getName()).log(Level.SEVERE, null, ex);
        } 
                    
    }//GEN-LAST:event_bIrAGNUActionPerformed

    private void bVerLicenciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bVerLicenciaActionPerformed
        try {
            Desktop.getDesktop().browse(new URI("http://www.viti.es/gnu/licenses/gpl.html"));
        } catch (Exception ex) {
            //TODO Implementar eeerrorr  I18N
            Logger.getLogger(PanelLicencia.class.getName()).log(Level.SEVERE, null, ex);
        } 
    }//GEN-LAST:event_bVerLicenciaActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bIrAGNU;
    private javax.swing.JButton bVerLicencia;
    private javax.swing.JScrollPane scrollLicencia;
    private javax.swing.JTextPane taLicencia;
    // End of variables declaration//GEN-END:variables
    
}
